﻿using B.S.Warehouse.ErrorCord;
using B.S.Warehouse.Write.Api.Application.Command.OutboundCommand;
using B.S.Warehouse.Write.Api.Application.Command.OutboundDetailsCommand;
using MediatR;
using Microsoft.AspNetCore.Mvc;

namespace B.S.Warehouse.Write.Api.Controllers
{
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class OutboundController : ControllerBase
    {
        private readonly IMediator mediator;
        public OutboundController(IMediator mediator)
        {
            this.mediator = mediator;
        }
        /// <summary>
        /// 出库管理添加
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<ApiResult<object>> AddOutbound(AddOutboundCommand request)
        {
            return await mediator.Send(request);
        }
        /// <summary>
        /// 出库管理删除
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        [HttpDelete]
        public async Task<ApiResult<int>> DelOutbound([FromQuery] DelOutboundCommand request)
        {
            return await mediator.Send(request);
        }
        /// <summary>
        /// 出库管理修改
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        [HttpPut]
        public async Task<ApiResult<int>> UpdateOutbound(UpdateOutboundCommand request)
        {
            return await mediator.Send(request);
        }

        /// <summary>
        /// 出库管理添加
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<ApiResult<object>> AddOutboundDetails(AddOutboundDetailsCommand request)
        {
            return await mediator.Send(request);
        }
        /// <summary>
        /// 出库管理删除
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        [HttpDelete]
        public async Task<ApiResult<int>> DelOutboundDetails([FromQuery] DelOutboundDetailsCommand request)
        {
            return await mediator.Send(request);
        }
        /// <summary>
        /// 出库管理修改
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        [HttpPut]
        public async Task<ApiResult<int>> UpdateOutboundDetails(UpdateOutboundDetailsCommand request)
        {
            return await mediator.Send(request);
        }
    }
}
